﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/// <summary>
/// 管理对话框
/// </summary>
public class DialogMgr : Singleton<DialogMgr>
{
    private List<Dialog> _allDialogs = new List<Dialog>();

    public T Open<T>() where T : Dialog, new()
    {
        var dlg = new T();
        _allDialogs.Add(dlg);
        return dlg;
    }

    public void Close(Dialog dlg)
    {
        _allDialogs.Remove(dlg);
        dlg.Close();
    }

    public void CloseAll()
    {
        foreach (var dlg in _allDialogs)
        {
            dlg.Close();
        }
        _allDialogs.Clear();
    }
}
